//
//  GoodsDetailBottomCartView.m
//  ABSallRec
//
//  Created by 我演示 on 2019/11/10.
//  Copyright © 2019 Jerry-Fu. All rights reserved.
//

#import "GoodsDetailBottomCartView.h"

@interface GoodsDetailBottomCartView ()
/**加入购物车*/
@property(nonatomic,weak) UIButton *addCartBtn ;

/**立即购买*/
@property(nonatomic,weak) UIButton *byeCartBtn ;


@end

@implementation GoodsDetailBottomCartView

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self makeUpGoodsUI];
        [self makeUpGoodsSubviews];
        
    }
    return  self;
}

-(void)makeUpGoodsUI{

    ///1: 添加btn
    UIButton *shopbtn = [[UIButton alloc] initWithButtonText:@"店铺" textColor:[UIColor colorWithHexString:@"#333333"] textFont:11] ;
    [shopbtn setImage:[UIImage imageNamed:@"tabBar_new_click_icon"] forState:UIControlStateNormal];
    shopbtn.backgroundColor = UIColor.greenColor;
    [self addSubview:shopbtn];
    self.shopBtn = shopbtn ;
    
    /// 2：添加收藏的btn
    UIButton *collectBtn = [[UIButton alloc] initWithButtonText:@"收藏" textColor:[UIColor colorWithHexString:@"#333333"] textFont:11] ;
    [collectBtn setImage:[UIImage imageNamed:@"tabBar_new_click_icon"] forState:UIControlStateNormal];
    [collectBtn setBackgroundColor:[UIColor redColor]];
    [self addSubview:collectBtn];
    self.collectBtn = collectBtn;
    
    /// 添加加入到购物车的按钮
    UIButton *addCartBtn = [[UIButton alloc] initWithButtonText:@"加入购物车" textColor:[UIColor whiteColor] textFont:15];
    [addCartBtn addTarget:self action:@selector(pressAddCartBtn) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:addCartBtn];
    self.addCartBtn = addCartBtn;
    
    
}

/// 使用block进行弹窗
-(void)pressAddCartBtn {
    self.addCartBtnBlock();
    
}

-(void)makeUpGoodsSubviews {
    __weak __typeof(self) weakSelf = self;
    [self.shopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self).offset(0);
        make.width.equalTo(weakSelf.mas_width).multipliedBy(0.15);
    }];
    [self.shopBtn  setLayoutWithEdgeInsetsStyle:ABSButtonEdgeInsetsStyleTop imageTitleSpace:-3];
    
    [self.collectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.shopBtn.mas_right).offset(0);
        make.top.bottom.equalTo(self).offset(0);
        make.width.equalTo(weakSelf.shopBtn.mas_width).offset(0);
    }];
    [self.collectBtn  setLayoutWithEdgeInsetsStyle:ABSButtonEdgeInsetsStyleTop imageTitleSpace:-3];
    
    [self.addCartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.collectBtn.mas_right).offset(0);
          make.top.bottom.equalTo(self).offset(0);
        make.width.equalTo(weakSelf.mas_width).multipliedBy(0.3);
    }];
    
}

@end
